package com.immyc.item.consumer.controller;

import com.immyc.model.entity.User;
import com.immyc.user.server.UserServerService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description:
 * @Author:mayc
 * @Date:2019/5/12 22:32
 */
@RestController
public class UserController {

    @Reference
    private UserServerService userServerService;

    @GetMapping("hello/{msg}")
    public String say(@PathVariable String msg) {
        return this.userServerService.getMsg(msg);
    }

    @GetMapping("user/add")
    public String addUser(User user) {
        this.userServerService.addUser(user);
        return "添加成功";
    }

    @GetMapping("user/list")
    public List<User> findAll() {
        List<User> users = this.userServerService.findUsers();
        System.out.println(users.size());
        return users;
    }
}
